package com.hptpd.questionnairesurvey.vo;

import com.google.common.collect.Lists;
import com.hptpd.questionnairesurvey.domain.UserSurveyResult;
import com.hptpd.questionnairesurvey.utils.AbstractMyBeanUtils;
import lombok.Data;

import java.util.List;

/**
 * \* Created with IntelliJ IDEA.
 * \* Date: 2019/12/18
 * \*
 * \* Description:
 * \
 *
 * @author walter_long
 */
@Data
public class UserSurveyResultVo {
    private String id;

    private String answer;

    private String type;

    private QuestionVo questionVo;

    public static List<UserSurveyResultVo> convertUserSurveyResult(List<UserSurveyResult> userSurveyResults) {
        List<UserSurveyResultVo> userSurveyResultResultVos = Lists.newLinkedList();
        for (UserSurveyResult userSurveyResult : userSurveyResults) {
            userSurveyResultResultVos.add(convertUserSurveyResult(userSurveyResult));
        }
        return userSurveyResultResultVos;
    }

    public static UserSurveyResultVo convertUserSurveyResult(UserSurveyResult userSurveyResult) {
        if (null == userSurveyResult) {
            return null;
        }
        UserSurveyResultVo userSurveyResultResultVo = new UserSurveyResultVo();
        AbstractMyBeanUtils.copyProperties(userSurveyResult, userSurveyResultResultVo);
        QuestionVo questionVo = new QuestionVo();
        questionVo.setId(null != userSurveyResult.getQuestion() ? userSurveyResult.getQuestion().getId() : "");
        userSurveyResultResultVo.setQuestionVo(questionVo);
        return userSurveyResultResultVo;
    }
}
